/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.unice.miage.entities;

import fr.unice.miage.enumeration.TypeOperation;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author remi
 */
@Entity
public class OperationBanquaire implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @ManyToOne
    private CompteBanquaire compteA;
    
    @ManyToOne
    private CompteBanquaire compteB;
    
    private float montant;
    
    private TypeOperation typeoperation;
    
    @Temporal(TemporalType.DATE)
    private Date dateoperation;
    
    /* Constructeur */
    public OperationBanquaire(){}
    public OperationBanquaire(CompteBanquaire ca, float montant, TypeOperation type)
    {
        this.compteA = ca;
        this.montant = montant;
        this.typeoperation = type;
        this.dateoperation = new Date();
    }
    
    public OperationBanquaire(CompteBanquaire ca,CompteBanquaire cb, float montant, TypeOperation type)
    {
        this.compteA = ca;
        this.compteB = cb;
        this.montant = montant;
        this.typeoperation = type;
        this.dateoperation = new Date();
    }
    
    /* Getter / Setter */
    public Date getDateoperation() {
        return dateoperation;
    }

    public void setDateoperation(Date dateoperation) {
        this.dateoperation = dateoperation;
    }
    
    public CompteBanquaire getCompteA() {
        return compteA;
    }

    public void setCompteA(CompteBanquaire compteA) {
        this.compteA = compteA;
    }

    public CompteBanquaire getCompteB() {
        return compteB;
    }

    public void setCompteB(CompteBanquaire compteB) {
        this.compteB = compteB;
    }

    public float getMontant() {
        return montant;
    }

    public void setMontant(float montant) {
        this.montant = montant;
    }

    public Enum<TypeOperation> getTypeoperation() {
        return typeoperation;
    }

    public void setTypeoperation(TypeOperation typeoperation) {
        this.typeoperation = typeoperation;
    }
    
    

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OperationBanquaire)) {
            return false;
        }
        OperationBanquaire other = (OperationBanquaire) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.unice.miage.entities.Operation[ id=" + id + " ]";
    }
    
}
